package com.htkj.questservice

import android.accessibilityservice.AccessibilityService
import android.util.Log
import android.view.accessibility.AccessibilityEvent

class MyAccessibilityService : AccessibilityService() {
    override fun onAccessibilityEvent(event: AccessibilityEvent?) {
        Log.d("MyAccessibilityService", event.toString())
        event?.let {
            if (it.eventType  == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
                val packageName = it.packageName?.toString()
                val className = it.className?.toString()
                if (!packageName.isNullOrEmpty())  {
                    Log.d("MyAccessibilityService", "当前应用: $packageName, 类名: $className")
                    // 在这里处理包名逻辑（如发送广播、存储等）
                }
            }
        }
    }

    override fun onInterrupt() {
        Log.w("MyAccessibilityService", "服务被中断")
    }
}